package com.mobilekites.api;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONObject;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;

public class DfeApiImpl implements DfeApi {
	private final RequestQueue mQueue;

	public DfeApiImpl(RequestQueue requestQueue) {
		mQueue = requestQueue;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Request<JSONObject> getConfig(Listener<JSONObject> listener,
			ErrorListener errorListener) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("cmd", "getconfig");
		DfeRequest request = new DfeRequest(BASE_URI, params, listener,
				errorListener);
		return mQueue.add(request);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Request<JSONObject> registerAndroid(String deviceId,
			String registrationId, Listener<JSONObject> listener,
			ErrorListener errorListener) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("cmd", "registerAndroid");
		params.put("deviceid", deviceId);
		params.put("gcmid", registrationId);
		params.put("params", "deviceid,gcmid,appid");
		DfeRequest request = new DfeRequest(BASE_URI, params, listener,
				errorListener);
		return mQueue.add(request);
	}
}
